package com.ostrich.module_home.daily

import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.ostrich.library_base.BaseMvvmFragment
import com.ostrich.library_common.utils.LoggerUtils
import com.ostrich.module_home.R
import com.ostrich.module_home.daily.adapter.DailyAdapter
import com.ostrich.module_home.databinding.HomeFragmentDailyBinding


class DailyFragment : BaseMvvmFragment<HomeFragmentDailyBinding,DailyViewModel>() {
    private lateinit var dailyAdapter: DailyAdapter
    override fun initView() {
        binding?.let {
            dailyAdapter = DailyAdapter()
            it.rv.adapter = dailyAdapter
            it.rv.layoutManager = LinearLayoutManager(context)
            it.rv.setHasFixedSize(true)
        }

    }

    override fun initData() {
       viewModel.daily().observe(this){
           LoggerUtils.d(TAG,it.toString())
           dailyAdapter.setList(it.itemList)
       }
    }

    override fun initListener() {

    }

    override fun bindLayout(): Int {
        return R.layout.home_fragment_daily
    }

    override fun getJVMClass(): Class<DailyViewModel> {
       return DailyViewModel::class.java
    }

    companion object{
        const val TAG = "DailyFragment"
    }

}